
const { ccclass, property } = cc._decorator;

@ccclass
export default class LyTipPre extends cc.Component {
    @property({ type: cc.Node, tooltip: '箭头按钮' }) arrow: cc.Node = null
    @property({ type: cc.Label, tooltip: '提示label' }) tipLab: cc.Label = null
    @property({ type: cc.Node, tooltip: '提示节点' }) tipNode: cc.Node = null
    isRight: boolean = null             //方向

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {

    }

    // update (dt) {}
    /**
     * 初始化提示
     * @param isRight 是否右边
     * @param tip 提示内容
     */
    init(isRight: boolean, tip: string) {
        let anchorX, angle, arrowX;
        if (isRight) {
            anchorX = 1
            angle = 30
            arrowX = -40
        } {
            anchorX = 0
            angle = 30
            arrowX = 40
        }
        this.arrow.angle = angle
        this.arrow.x = arrowX
        this.node.anchorX = anchorX
        this.tipLab.string = `${tip}`
        this.arrow.active = true
        this.tipNode.active = false
    }

    btnServer() {
        this.arrow.active = false
        this.tipNode.active = true
    }

    tipNodeClickServer() {
        this.arrow.active = true
        this.tipNode.active = false
    }
}
